class Room < ActiveRecord::Base
  belongs_to :event
  has_many :conventioners,:dependent=>:nullify
  has_many :users,:through=>:conventioners,:source=>:user
  validates_presence_of :name,:message =>"您添加的房间没有房间号吗?"

  def self.search(search, page)
    paginate :per_page => 10, :page => page,
    :conditions => ['room_category like ?', "%#{search}%"],
    :order => 'room_category'
  end
end
